﻿########################################################
#    http://michlstechblog.info/blog/powershell-show-a-messagebox/
########################################################

# Load assembly
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms");

#show the messagebox
$oReturn=[System.Windows.Forms.Messagebox]::Show("This is the Message text")

<# 
返回值 : 
            [system.enum]::getValues($oReturn.GetType())
            None
            OK
            Cancel
            Abort
            Retry
            Ignore
            Yes
            No

上述返回值 的 5种组合方式
[system.enum]::getNames([System.Windows.Forms.MessageBoxButtons]) |  foreach{[console]::Writeline("{0,20} {1,-40:D}",$_,[System.Windows.Forms.MessageBoxButtons]::$_.value__)}
                  OK 0
            OKCancel 1
    AbortRetryIgnore 2
         YesNoCancel 3
               YesNo 4
         RetryCancel 5
#>

# 弹出框包含OK,和Cancel两个按钮
$oReturn=[System.Windows.Forms.MessageBox]::Show("Message Text","Title",[System.Windows.Forms.MessageBoxButtons]::OKCancel)	
switch ($oReturn){
	"OK" {
		write-host "You pressed OK"
		# Enter some code
	} 
	"Cancel" {
		write-host "You pressed Cancel"
		# Enter some code
	} 
}
